<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="./js/jquery.min.js"></script>
	</head>
	<body>
		<h1>写死JSON,解析json字符串</h1>
		
		<div>
			
			<div>价格：<span id="itemID"></span></div>
			<div>编号：<span id="itemPrice"></span></div>
			
		</div>
	
	</body>
	
	<script>
		
		var jsonstr='[{"p":"2499.00","op":"2499.00","cbf":"0","id":"J_100003717483","m":"10000.00"}]';
		console.log(jsonstr);
		
		//选出字符串中的p和id---
		//JSON提供的方法parse会自动解析成对象
		//通过对象object.p   object.id获取对象属性值
		  var items=JSON.parse(jsonstr);
		 console.log(items[0]);
		  console.log(items[0].p);
		  console.log(items[0].id);
		  
		 $("#itemID").text(items[0].p) ;
		 $("#itemID").css("color","green")
		 
		 var a=$("#itemPrice").text(items[0].id) ;
		  a.css("color","red")
		  
		  
		  
	</script>
	
</html>
